package com.zmm.study.order.controller;

import com.zmm.common.base.model.Result;
import com.zmm.common.base.model.ResultCode;
import com.zmm.study.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author 900045
 * @description:
 * @name OrderCloseController
 * @date By 2021-10-20 10:08:03
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrderCloseController {
	
	@Resource
	private OrderService orderService;

	/**
	 * 模拟 主动关闭订单 -- 部分取消 -- 暂时用不到(没有支付 是没有部分取消的操作)
	 * @author: 900045
	 * @date: 2021-10-20 10:08:55
	 * @throws 
	 * @param orderNo: 
	 * @param skuId:
	 * @param skuNum:
	 * @param wareId:   
	 * @return: com.zmm.common.base.model.Result
	 **/
	@GetMapping("/test/close/order")
	public Result closeOrderTest(String orderNo,Long skuId,Integer skuNum,Long wareId){
		
		orderService.unLockStock(orderNo,skuId,skuNum,wareId);
		return Result.ok(ResultCode.SUCCESS);
	}

	
	/**
	 * 模拟 主动关闭订单 -- 全部
	 * @author: 900045
	 * @date: 2021-10-21 11:21:58
	 * @throws 
	 * @param orderNo: 
	 * @return: com.zmm.common.base.model.Result
	 **/
	@GetMapping("/test/close/all/order")
	public Result closeAllOrderTest(String orderNo){

		orderService.closeOrder(orderNo);
		orderService.unLockStock(orderNo);
		return Result.ok(ResultCode.SUCCESS);
	}
}
